package com.example.pcl.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.pcl.pojo.dto.AppointmentQueryDto;
import com.example.pcl.pojo.entity.Appointments;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.pcl.pojo.vo.AppointmentVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 预约表，记录学生与心理咨询师的预约信息 Mapper 接口
 * </p>
 *
 * @author xx
 * @since 2024-12-17
 */
@Mapper
public interface AppointmentsMapper extends BaseMapper<Appointments> {

    IPage<AppointmentVo> pageList(Page<?> page, AppointmentQueryDto queryDto);

    // 查询总的预约量
    @Select("SELECT COUNT(*) FROM appointments")
    int countTotalAppointments();

    // 查询待确认预约量
    @Select("SELECT COUNT(*) FROM appointments WHERE status = #{status}")
    int countPendingAppointments(@Param("status") int status);

    // 查询已完成的咨询量
    @Select("SELECT COUNT(*) FROM appointments WHERE status = #{status}")
    int countCompletedAppointments(@Param("status") int status);

    AppointmentVo finById(Integer appointmentId);
}
